ie5  = (document.all && document.getElementById);
ns6  = (!document.all && document.getElementById);
opac = 0;
opac_out = 100;

function browser(){
	var browser=navigator.appName;
	if(browser != "Netscape"){
		alert('WARNING !\n\nYour browser is NOT supported !\nThis computer program WILL NOT work correctly under your web browser.\n\nWE RECOMMEND MOZILLA FIREFOX');
		location.href='http://www.mozilla.com';
	}
}


function go_in(layer_ref){
	document.getElementById(layer_ref).style.display  = "block";
}

function go_out(layer_ref){
	document.getElementById(layer_ref).style.display  = "none";
}


function get_big_image(web_root , filecode , width, height , top){

	document.getElementById(filecode + "_download_info").style.display = "block";
	document.getElementById(filecode).style.display = "block";
	document.getElementById(filecode).innerHTML = "";
	


	

	document.getElementById(filecode).innerHTML += "<span id='here'>";
	document.getElementById(filecode).innerHTML += "<img src='" + web_root + "download.php?type=temp_thumb&filecode=" + filecode + "' style='cursor:pointer; z-index:250;' />";
	document.getElementById(filecode).innerHTML += "</span>";

	
	if(height <= 150){
		document.getElementById(filecode).style.top = parseInt(top)+22;
		document.getElementById(filecode).style.width = parseInt(width)+150;
		document.getElementById(filecode).style.height = parseInt(height)+150;
	}
	setTimeout("location.href='#here_" + filecode + "'" , 10);
}


function fadeIn(layer_ref, to){
	document.getElementById(layer_ref).style.display  = "block";
	
}

function fadeOut(layer_ref){
	document.getElementById(layer_ref).style.display  = "none";
}

by_init=0;
function slide_down(layer_ref , by){
	
	document.getElementById(layer_ref).style.display  = "block";
	if(ie5) document.getElementById(layer_ref).filters.alpha.opacity = 100;
	if(ns6) document.getElementById(layer_ref).style.MozOpacity = 1.0;

	if(by_init < by){
		by_init = by_init + 30;
		document.getElementById(layer_ref).style.width = by_init;
		setTimeout("slide_down('"+layer_ref+"', '"+by+"')" , 1);
	}else{
		by_init=0;
	}
	
}


function changeSomeStuff(){
	if(document.getElementById('options').style.display  == "none"){
		fadeIn('options');
		document.getElementById('drop').src = "images/drop_up.gif";
		document.getElementById('show_text').innerHTML = "Hide Options";
	}else{
		fadeOut('options');
		document.getElementById('drop').src = "images/drop.gif";
		document.getElementById('show_text').innerHTML = "Show Options";
	}
}
function swap(layer_ref){
	if(document.getElementById(layer_ref).style.display  == "none"){
		go_in(layer_ref);
	}else{
		go_out(layer_ref);
	}
}

function delete_file(filecode){
	

	xmlHttp = ajaxFunction();
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState < 4){
			document.getElementById(filecode+'_rem_label').style.background = '#FF0000';
			document.getElementById(filecode+'_rem_label').style.color = '#FFFFFF';
			document.getElementById(filecode+'_rem_label').innerHTML = 'Deleting file...';
		}else{
			document.getElementById(filecode+'_rem_label').style.background = '#FFFFD2';
			document.getElementById(filecode+'_rem_label').style.color = '#808080';
			document.getElementById(filecode+'_rem_label').innerHTML = 'Delete this file...';
			if(xmlHttp.responseText != "Your access is forbidden. Thank you."){
				document.getElementById(filecode+'_image_holder').innerHTML = '<b>FILE DELETED...</b>';
				document.getElementById(filecode+'_image_holder').className = 'deleted_div';
			}else{
				alert(xmlHttp.responseText);
			}
		}
	}
	xmlHttp.open("GET",
		"ajax.php?a=remove_file&filecode=" + filecode,
		true);
	xmlHttp.send(null);
}

function vote(filecode,direction){
	

	xmlHttp = ajaxFunction();
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState < 4){

		}else{
			alert(xmlHttp.responseText);
		}
	}
	xmlHttp.open("GET",
		"ajax.php?a=vote&filecode=" + filecode + "&direction=" + direction,
		true);
	xmlHttp.send(null);
}

function display_email_dialog(filecode){
	swap(filecode+"_email_dialog");
	setTimeout("location.href='#here_" + filecode + "'" , 10);
}